package com.example.demo.utils;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

/**
 * @Description
 * @Author chenhuiyu
 * @Date 2023/12/19
 */
public class ExcelUtil {
    private void setExcelHead(Workbook workbook) {
        if (workbook != null) {
            Sheet sheet = workbook.getSheetAt(0);
            Row excelRow;
            Cell cell;
            excelRow = sheet.createRow(0);
            String[] title = new String[]{"第1列", "第2列", "第3列", "第4列", "第5列"};

            for (int i = 0; i < title.length; i++) {
                cell = excelRow.createCell(i);
                cell.setCellValue(title[i]);
            }
        }
    }
}
